﻿using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Collections.ObjectModel;
using System.Collections.Generic;


namespace cz.uhul.DSMLv2
{



  public class SubstringsOp : AttrDescription
  {


    public SubstringsOp()
      : base()
    { }




    [XmlElement(ElementName = "initial", Form = XmlSchemaForm.None, IsNullable = false)]
    public string Initial 
    {
      get
      {
        if (String.IsNullOrEmpty(Operation))
          return null;

        return (Operation == "initial") ?  Value : null;
      }
      set
      {
        if (!String.IsNullOrEmpty(Operation))
          throw new InvalidSearchFilterException("cant set initial, " + Operation + " allready exists");

        Value = value;
        Operation = "initial";
      }
    }






    [XmlElement(ElementName = "any", Form = XmlSchemaForm.None, IsNullable = false)]
    public string Any
    {
      get
      {
        if (String.IsNullOrEmpty(Operation))
          return null;

        return (Operation == "any") ? Value : null;
      }
      set
      {
        if (!String.IsNullOrEmpty(Operation))
          throw new InvalidSearchFilterException("cant set initial, " + Operation + " allready exists");

        Value = value;
        Operation = "any";
      }
    }






    [XmlElement(ElementName = "final", Form = XmlSchemaForm.None, IsNullable = false)]
    public string Final
    {
      get
      {
        if (String.IsNullOrEmpty(Operation))
          return null;

        return (Operation == "final") ? Value : null;
      }
      set
      {
        if (!String.IsNullOrEmpty(Operation))
          throw new InvalidSearchFilterException("cant set initial, " + Operation + " allready exists");

        Value = value;
        Operation = "final";
      }
    }




    [XmlIgnore]
    public string Operation { get; set; }




    [XmlIgnore]
    public string Value { get; set; }



  }

}
